<template>
    <div>
        <button @click="add">add</button>
    </div>
</template>
<script>
import { mapState, mapGetters, mapActions } from 'vuex'
export default {
  data () {
    return {
      name: ''
    }
  },
  computed: {
    ...mapState(['userId']),
    ...mapGetters(['getCity'])
  },
  mounted () {
    console.log(this.userId)
    console.log(this.getCity)
  },
  methods: {
    // 导出所有的方法
    ...mapActions(['setCityName']),
    add () {
      this.setCityName('杭州')
      console.log(this.getCity)
    }
  }
}
</script>
